/**
 * @author Jjn
 * @since 2021-06-12 11:18
 */
public class Solution5_1 {
    
    public String replaceSpace(String s) {
        if (s == null) {
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        int length = s.length();
        for (int i = 0; i < length; i++) {
            char ithChar = s.charAt(i);
            if (ithChar == ' ') {
                stringBuilder.append("%20");
            } else {
                stringBuilder.append(ithChar);
            }
        }
        return stringBuilder.toString();
    }
    
    public static void main(String[] args) {
        Solution5_1 solution51 = new Solution5_1();
        System.out.println(solution51.replaceSpace("We are happy. "));
    }
}
